package com.umgsai.thread.thread73;

public class Service {

	int num = 0;
	 synchronized public void add(String username) {
		try {
			if (username.equals("a")) {
				num = 100;
				System.out.println("a set done" + System.currentTimeMillis());
				Thread.sleep(2000);
			}else if (username.equals("b")) {
				num = 200;
				System.out.println("b set done" + System.currentTimeMillis());
				Thread.sleep(2000);
			}
			System.out.println("username=" + username + ",num=" + num);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
